/* ==========================================================================
   Components — avatars, messages, modals, menus, and call UI
   ========================================================================== */

/* ------------------------------- Avatars -------------------------------- */

.avatar {
  position: relative;
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: visible;
  user-select: none;
}
.avatar__img,
.avatar__fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
}
.avatar__img {
  object-fit: cover;
}
.avatar__fallback {
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  font-size: 0.4em;
  user-select: none;
}
.avatar--xs { width: 20px; height: 20px; font-size: 20px; }
.avatar--sm { width: 24px; height: 24px; font-size: 24px; }
.avatar--md { width: 32px; height: 32px; font-size: 32px; }
.avatar--lg { width: 40px; height: 40px; font-size: 40px; }
.avatar--xl { width: 80px; height: 80px; font-size: 80px; }

.avatar__status {
  position: absolute;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 3px solid var(--bg-raised);
  width: 10px;
  height: 10px;
  box-sizing: content-box;
}
.avatar--lg .avatar__status { width: 14px; height: 14px; border-width: 4px; }

.avatar__status[data-status="online"] { background: var(--status-online); }
.avatar__status[data-status="idle"] { background: var(--status-idle); }
.avatar__status[data-status="dnd"] { background: var(--status-dnd); }
.avatar__status[data-status="offline"] { background: var(--status-offline); }
.avatar__status[data-status="invisible"] { background: transparent; border-color: transparent; }

.avatar-wrap {
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
}
.avatar-wrap[data-status="offline"] .avatar {
  filter: grayscale(1);
  opacity: 0.45;
}
.avatar-wrap[data-mention="true"] .avatar {
  box-shadow: 0 0 0 2px var(--red);
}
.avatar-wrap[data-hover-ring="true"]:hover .avatar {
  box-shadow: 0 0 0 2px var(--brand);
}

/* ------------------------------ Messages ------------------------------- */

.msg {
  --msg-pad: 4px 48px;
  position: relative;
  padding: var(--msg-pad);
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 16px;
}
.msg:hover {
  background: var(--bg-hover);
}
.msg[data-first="false"] {
  margin-top: calc(var(--msg-gap) * -1 + 2px);
}
.msg[data-compact="true"] {
  --msg-pad: 1px 48px;
}

.msg__gutter {
  display: flex;
  justify-content: center;
  padding-top: 2px;
}
.msg__timestamp-hover {
  display: none;
  font-size: var(--fs-xs);
  color: var(--text-faint);
  line-height: 22px;
}
.msg:hover .msg__timestamp-hover {
  display: block;
}

.msg__body {
  min-width: 0;
}

.msg__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.msg__author {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-normal);
  cursor: pointer;
}
.msg__author:hover {
  text-decoration: underline;
}
.msg__bot-tag {
  background: var(--brand);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 1px 4px;
  border-radius: 3px;
  position: relative;
  top: -1px;
}
.msg__timestamp {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.msg__edited {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.msg__text {
  font-size: var(--fs-base);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg__text code {
  font-family: var(--font-mono);
  font-size: 85%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 3px;
}
.msg__text pre {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  overflow-x: auto;
  margin: 6px 0;
}
.msg__text pre code {
  background: none;
  border: 0;
  padding: 0;
}
.msg__text blockquote {
  margin: 4px 0;
  padding-left: 12px;
  border-left: 4px solid var(--border-strong);
  color: var(--text-muted);
}

.msg__mention {
  background: var(--brand-soft);
  color: var(--text-link);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 500;
  cursor: pointer;
}
.msg__mention:hover {
  background: var(--brand);
  color: #fff;
}
.msg__mention[data-me="true"] {
  background: rgba(240, 178, 50, 0.3);
  color: var(--yellow);
}

.msg__emoji {
  width: 1.375em;
  height: 1.375em;
  vertical-align: -0.3em;
  object-fit: contain;
}

/* System message */
.msg--system {
  grid-template-columns: 40px minmax(0, 1fr);
}
.msg--system .msg__text {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Reply reference */
.msg__reply {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: 2px;
  cursor: pointer;
  position: relative;
}
.msg__reply::before {
  content: "";
  position: absolute;
  left: -40px;
  top: 50%;
  width: 32px;
  height: 10px;
  border-left: 2px solid var(--border-strong);
  border-top: 2px solid var(--border-strong);
  border-top-left-radius: 6px;
}
.msg__reply:hover .msg__reply-author {
  color: var(--text-normal);
}
.msg__reply-author {
  font-weight: 500;
}
.msg__reply span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Attachments */
.msg__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.att {
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: var(--bg-deep);
  max-height: 350px;
  display: flex;
}
.att img,
.att video {
  max-width: 100%;
  max-height: 350px;
  display: block;
  object-fit: contain;
  cursor: pointer;
}
.att__file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-base);
}
.att__name {
  flex: 1;
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att__size {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

/* Reactions */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.reaction {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  height: 24px;
  border-radius: 8px;
  background: var(--bg-base);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.reaction:hover {
  border-color: var(--border-strong);
}
.reaction[data-mine="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.reaction__count {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.reaction[data-mine="true"] .reaction__count {
  color: var(--text-link);
}
.reaction__add {
  color: var(--text-faint);
  font-size: var(--fs-md);
}

/* Hover toolbar */
.msg__tools {
  position: absolute;
  top: -16px;
  right: 16px;
  display: none;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  z-index: 2;
}
.msg:hover .msg__tools {
  display: flex;
}
.msg__tools button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border-radius: 3px;
}
.msg__tools button:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}

/* ------------------------------- Buttons ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-normal);
  background: var(--bg-raised);
  border: 1px solid transparent;
  transition: background-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--brand); color: var(--text-on-brand); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--primary:active { background: var(--brand-active); }

.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { background: var(--red-hover); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--bg-hover); }

.btn--sm { height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn--block { width: 100%; }

.iconbtn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.iconbtn:hover { background: var(--bg-hover); color: var(--text-normal); }
.iconbtn[aria-pressed="true"] { background: var(--bg-active); color: var(--text-normal); }
.iconbtn--danger:hover { color: var(--text-danger); }

/* -------------------------------- Forms -------------------------------- */

.field { margin-bottom: 20px; }
.field__label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.field__hint { font-size: var(--fs-xs);  color: var(--text-faint); margin-top: 6px; }
.field__error { font-size: var(--fs-sm); color: var(--text-danger); margin-top: 6px; }

.input,
.textarea,
.select {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-normal);
  outline: none;
  transition: border-color var(--dur) var(--ease);
}
.input:focus,
.textarea:focus,
.select:focus { border-color: var(--brand); }
.input::placeholder,
.textarea::placeholder { color: var(--text-faint); }
.textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.input--invalid { border-color: var(--red); }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
}
.checkbox input { margin-top: 3px; accent-color: var(--brand); }
.checkbox__text { font-size: var(--fs-base); }
.checkbox__sub { font-size: var(--fs-xs); color: var(--text-faint); }

/* Switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch__track {
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: var(--status-offline);
  position: relative;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
  flex: 0 0 auto;
}
.switch__track[data-on="true"] { background: var(--brand); }
.switch__thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--dur) var(--ease);
}
.switch__track[data-on="true"] .switch__thumb { transform: translateX(16px); }

/* ------------------------------- Modals -------------------------------- */

.modals {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: auto;
  animation: fade-in var(--dur) var(--ease);
}

.modal {
  background: var(--bg-mod);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pop-in var(--dur) var(--ease);
}
.modal--wide { max-width: 640px; }
.modal--tall { height: 85vh; }

.modal__header {
  padding: 24px 24px 8px;
  text-align: center;
  flex: 0 0 auto;
}
.modal__title { font-size: var(--fs-xl); margin: 0 0 8px; font-weight: 700; }
.modal__subtitle { color: var(--text-muted); font-size: var(--fs-base); margin: 0; }

.modal__body {
  padding: 16px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal__footer {
  padding: 16px 24px 24px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex: 0 0 auto;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------- Popovers ------------------------------ */

.popovers {
  position: fixed;
  inset: 0;
  z-index: 110;
  pointer-events: none;
}
.popover {
  position: absolute;
  background: var(--bg-float);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  pointer-events: auto;
  min-width: 200px;
  max-width: 320px;
  animation: pop-in var(--dur) var(--ease);
}

/* ---------------------------- Context menus ---------------------------- */

.contextmenu {
  position: fixed;
  z-index: 130;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px 8px;
  min-width: 188px;
  max-width: 260px;
}
.contextmenu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: left;
}
.contextmenu__item:hover { background: var(--brand); color: #fff; }
.contextmenu__item[data-danger="true"]:hover { background: var(--red); }
.contextmenu__item[disabled] { opacity: 0.4; cursor: not-allowed; }
.contextmenu__item[disabled]:hover { background: none; color: var(--text-muted); }
.contextmenu__divider { height: 1px; background: var(--border-strong); margin: 4px 0; }
.contextmenu__label {
  padding: 6px 8px 2px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ------------------------------- Tooltips ------------------------------ */

.tooltip {
  position: fixed;
  z-index: 140;
  background: var(--bg-deep);
  color: var(--text-normal);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow);
  pointer-events: none;
  max-width: 280px;
}

/* -------------------------------- Toasts ------------------------------- */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow);
  animation: pop-in var(--dur) var(--ease);
  max-width: 420px;
}
.toast[data-kind="error"] { border-color: var(--red); color: var(--text-danger); }
.toast[data-kind="success"] { border-color: var(--green); }

/* ------------------------------ Emoji picker ---------------------------- */

.emojipicker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}
.emojipicker__cat {
  grid-column: 1 / -1;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 4px 4px;
}
.emojipicker__item {
  font-size: 22px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}
.emojipicker__item:hover { background: var(--bg-hover); }

/* --------------------------------- Auth -------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(88, 101, 242, 0.22), transparent),
    var(--bg-deep);
}
.auth__card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-mod);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth__title { font-size: var(--fs-2xl); margin: 0 0 6px; text-align: center; }
.auth__subtitle { color: var(--text-muted); text-align: center; margin: 0 0 24px; font-size: var(--fs-base); }
.auth__switch { text-align: center; font-size: var(--fs-sm); margin-top: 16px; color: var(--text-muted); }
.auth__error {
  background: rgba(218, 55, 60, 0.1);
  border: 1px solid var(--red);
  color: var(--text-danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: var(--fs-sm);
  margin-bottom: 16px;
}
.auth__notice {
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: var(--fs-sm);
  margin-bottom: 16px;
}
.auth__code {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  letter-spacing: 0.3em;
  text-align: center;
  padding: 12px;
  background: var(--bg-deep);
  border-radius: var(--radius);
  margin: 12px 0;
}

/* ------------------------------- Call UI -------------------------------- */

.callbar {
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.callbar__info { min-width: 0; flex: 1; }
.callbar__title { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.callbar__status { font-size: var(--fs-xs); color: var(--green); }
.callbar__status[data-state="connecting"],
.callbar__status[data-state="ringing"] { color: var(--yellow); }
.callbar__status[data-state="failed"] { color: var(--text-danger); }
.callbar__controls { display: flex; gap: 4px; align-items: center; }
.callbar button[data-active="true"] { background: var(--red); color: #fff; }

.callstage {
  position: absolute;
  inset: 0;
  z-index: 90;
  background: #1a1b1e;
  display: grid;
  place-items: center;
  gap: 16px;
}
.callstage__grid {
  display: grid;
  gap: 8px;
  padding: 16px;
  width: 100%;
  height: 100%;
  align-content: center;
  justify-content: center;
}
.callstage__tile {
  position: relative;
  background: #2b2d31;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-width: 240px;
}
.callstage__tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.callstage__tile[data-video="false"] video { display: none; }
.callstage__tile .avatar-wrap {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
}
.callstage__label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.65);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--fs-xs);
  display: flex;
  align-items: center;
  gap: 6px;
}

.callstage__incoming {
  background: var(--bg-mod);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.callring {
  position: fixed;
  inset: 0;
  z-index: 160;
  background: rgba(0, 0, 0, 0.82);
  display: grid;
  place-items: center;
}
.callring__inner {
  background: var(--bg-mod);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.callring__actions { display: flex; gap: 16px; justify-content: center; margin-top: 24px; }
.callring button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-lg);
}
.callring__accept { background: var(--green); color: #fff; }
.callring__decline { background: var(--red); color: #fff; }

/* Voice channel rows get a connected indicator */
.chan[data-connected="true"] .chan__hash { color: var(--green); }
.chan__avatars { display: flex; }
.chan__avatars .avatar { margin-left: -6px; border: 2px solid var(--bg-base); }

/* ------------------------------- Threads -------------------------------- */

.threadpane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Threads sit under their parent channel, indented and visually lighter so
   the hierarchy is readable without a separate panel. */
.chan__threads {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
}

.chan--thread {
  height: 26px;
  padding-left: 4px;
}

.chan--thread .chan__hash { color: var(--text-faint); display: flex; }
.chan--thread .chan__name { font-size: var(--fs-sm); color: var(--text-muted); }
.chan--thread:hover .chan__name { color: var(--text-normal); }
.chan--thread[data-active="true"] .chan__name { color: var(--text-normal); font-weight: 500; }
.chan--thread[data-active="true"] { background: var(--bg-selected); border-radius: var(--radius-sm); }

/* Keyboard focus is the only way to open a thread without a pointer, so it
   has to be visible. */
.chan--thread:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* Breadcrumb back to the parent channel when a thread is open. */
.chat__crumb {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  white-space: nowrap;
  flex-shrink: 0;
}
.chat__crumb:hover { background: var(--bg-hover); color: var(--text-normal); }
.chat__crumb svg { transform: rotate(180deg); }

/* ------------------------------- Settings ------------------------------- */

.settings {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.settings__nav {
  background: var(--bg-base);
  padding: 16px 6px;
  overflow-y: auto;
}
.settings__navitem {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: 2px;
}
.settings__navitem:hover { background: var(--bg-hover); color: var(--text-normal); }
.settings__navitem[aria-current="true"] { background: var(--bg-selected); color: var(--text-normal); }
.settings__panel { padding: 24px 28px; overflow-y: auto; }
.settings__title { font-size: var(--fs-xl); margin: 0 0 20px; }

/* ------------------------------ Progress ------------------------------- */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--text-faint);
  font-size: var(--fs-md);
  padding: 40px;
  text-align: center;
}

/* ------------------------------- Invite embed ---------------------------- */

.invite-embed {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg-base);
}

.invite-embed__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.invite-embed__icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--brand);
  display: grid;
  place-items: center;
}

.invite-embed__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.invite-embed__meta {
  flex: 1;
  min-width: 0;
}

.invite-embed__name {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-embed__stats {
  display: flex;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.invite-embed__desc {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: 16px;
  line-height: 1.5;
}

.invite-embed__actions {
  display: flex;
  gap: 8px;
}

.invite-embed__actions .btn {
  flex: 1;
}

/* ------------------------------- Friends view --------------------------- */

.friends-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  background: var(--bg-base);
}

.friends {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.friends__tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  flex: 0 0 auto;
}

.friends__tab {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.friends__tab:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}

.friends__tab[data-active="true"] {
  background: var(--bg-active);
  color: var(--text-normal);
}

.friends__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.friends__content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.friends__category {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 12px 0 6px;
}

.friends__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}

.friends__row:hover {
  background: var(--bg-hover);
}

.friends__info {
  flex: 1;
  min-width: 0;
}

.friends__name {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friends__username {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.friends__actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.friends__add {
  max-width: 520px;
  margin: 24px auto;
  padding: 24px;
}

.friends__add-title {
  font-size: var(--fs-xl);
  margin: 0 0 4px;
}

.friends__add-subtitle {
  color: var(--text-muted);
  margin: 0 0 20px;
}

.friends__add-form {
  display: flex;
  gap: 8px;
}

.friends__add-form .input {
  flex: 1;
}

.friends__add-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(218, 55, 60, 0.1);
  border: 1px solid var(--red);
  color: var(--text-danger);
  font-size: var(--fs-sm);
}

.friends__add-success {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(87, 242, 135, 0.1);
  border: 1px solid var(--green);
  color: var(--green);
  font-size: var(--fs-sm);
}
