/* ==========================================================================
   ChitChat — components
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.2;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(.97);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 8px 20px rgba(108, 92, 231, .26);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 10px 26px rgba(108, 92, 231, .34);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background: rgba(108, 92, 231, .2);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

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

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-success {
  background: var(--success);
  color: #05231c;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 12.5px;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 11.5px;
}

.btn-lg {
  padding: 13px 24px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-icon .icon {
  width: 19px;
  height: 19px;
}

.link {
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
}

.link:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > label,
.label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-soft);
  letter-spacing: .01em;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
  background: var(--surface);
}

.textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.55;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input {
  padding-left: 40px;
}

.input-group > .icon,
.input-group > span:first-child {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

.input-suffix {
  position: absolute;
  right: 12px;
  font-size: 11.5px;
  color: var(--muted);
}

.hint {
  font-size: 11.5px;
  color: var(--muted);
}

.field-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 0;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 44px;
  height: 25px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform var(--transition);
}

.switch input:checked + .switch-track {
  background: var(--brand-gradient);
  border-color: transparent;
}

.switch input:checked + .switch-track::after {
  transform: translateX(19px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition);
}

.chip:hover {
  background: var(--surface-hover);
}

.chip.is-active {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}

.chip .icon {
  width: 15px;
  height: 15px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

.form-note .icon {
  color: var(--primary);
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.error-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.error-banner .icon {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */
.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-3);
  flex-shrink: 0;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
  line-height: 1;
  text-decoration: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
}

.avatar-ring {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-a);
}

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar-stack .avatar {
  margin-left: -8px;
  border: 2px solid var(--surface);
}

.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.status-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--surface);
}

/* --------------------------------------------------------------------------
   Cards, empty + loading states
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card-tight {
  padding: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-title h3 {
  font-size: 14.5px;
}

.card-title .icon {
  color: var(--muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-icon {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--brand-gradient-soft);
  color: var(--primary);
  margin-bottom: 6px;
}

.empty-icon .icon {
  width: 26px;
  height: 26px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 16px;
}

.empty-state p {
  font-size: 13px;
  max-width: 340px;
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: 12px;
}

.loading-block {
  display: grid;
  place-items: center;
  padding: 42px;
  width: 100%;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
  display: inline-block;
}

.spinner-sm {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: var(--skeleton);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.skeleton-card {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.skeleton-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.skeleton-line {
  height: 11px;
  width: 100%;
}

.skeleton-line.w40 { width: 40%; }
.skeleton-line.w25 { width: 25%; }
.skeleton-line.w90 { width: 90%; }
.skeleton-line.w70 { width: 70%; }

.skeleton-media {
  height: 190px;
  border-radius: var(--radius-md);
}

.inline-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  padding: 14px 0;
  justify-content: center;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Composer
   -------------------------------------------------------------------------- */
.composer {
  padding: 16px;
  margin-bottom: 18px;
}

.composer-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.composer-trigger {
  flex: 1;
  text-align: left;
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  transition: background var(--transition), border-color var(--transition);
}

.composer-trigger:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.composer-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex: 1;
  justify-content: center;
}

.composer-action:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.composer-action.image .icon { color: #22c55e; }
.composer-action.video .icon { color: #f43f5e; }
.composer-action.reel .icon { color: var(--primary); }

.composer-action input[type='file'] {
  display: none;
}

.composer-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.composer-modal textarea {
  border: 0;
  background: transparent;
  min-height: 120px;
  padding: 4px 2px;
  font-size: 17px;
  resize: none;
}

.composer-modal textarea:focus {
  box-shadow: none;
}

.composer-author {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
}

.composer-author .audience {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

.media-preview {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
}

.media-preview img,
.media-preview video {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  background: #000;
}

.media-preview .remove-media {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}

.media-preview .media-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.upload-progress {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}

.upload-progress span {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--brand-gradient);
  animation: indeterminate 1.2s ease infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* --------------------------------------------------------------------------
   Posts
   -------------------------------------------------------------------------- */
.feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post {
  padding: 16px;
  border-radius: var(--radius-lg);
  transition: border-color var(--transition);
}

.post:hover {
  border-color: var(--border-strong);
}

.post-header {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.post-meta {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.post-author {
  display: inline-block;
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.3;
}

.post-author:hover {
  text-decoration: underline;
}

.post-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.post-sub .icon {
  width: 12px;
  height: 12px;
}

.post-menu-btn {
  margin: -4px -6px 0 0;
}

.post-body {
  margin: 12px 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.post-media {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-3);
  margin: 4px 0 12px;
  border: 1px solid var(--border);
}

.post-media img,
.post-media video {
  display: block;
  width: 100%;
  max-height: 560px;
  object-fit: contain;
  background: #06060b;
}

.post-media video {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: contain;
}

.post-media.is-square img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.shared-post {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 4px 0 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.shared-post .post-media {
  margin: 8px 0 0;
  pointer-events: none;
  max-height: 260px;
}

.shared-post .post-body {
  margin: 8px 0 0;
  font-size: 13.5px;
}

.post-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  padding: 0 2px 10px;
}

.post-stats .stat-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.reaction-pill span {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 9px;
}

.reaction-pill .pill-like { background: var(--like); }
.reaction-pill .pill-dislike { background: var(--dislike); }

.post-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  transition: background var(--transition), color var(--transition);
  min-width: 0;
}

.action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.action-btn .icon {
  width: 18px;
  height: 18px;
}

.action-btn.is-liked {
  color: var(--like);
}

.action-btn.is-disliked {
  color: var(--dislike);
}

.reaction-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

.reaction-wrap .action-btn {
  width: 100%;
}

.reaction-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px;
  box-shadow: var(--shadow-md);
  z-index: 12;
  transform-origin: bottom left;
  animation: pop 140ms ease;
}

@keyframes pop {
  from { opacity: 0; transform: scale(.9) translateY(4px); }
  to { opacity: 1; transform: none; }
}

.reaction-pop button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
}

.reaction-pop button:hover {
  background: var(--surface-2);
  color: var(--like);
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

/* Comments */
.comments {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.comment-main {
  flex: 1;
  min-width: 0;
}

.comment-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 8px 12px;
  display: inline-block;
  max-width: 100%;
}

.comment-author {
  font-size: 12.5px;
  font-weight: 800;
  display: inline-block;
}

.comment-author:hover {
  text-decoration: underline;
}

.comment-text {
  font-size: 13px;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-top: 1px;
}

.comment-text.is-edited {
  opacity: .85;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 4px 0 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.comment-meta button {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  transition: color var(--transition);
}

.comment-meta button:hover {
  color: var(--text);
}

.comment-meta button.is-active {
  color: var(--like);
}

.comment-meta button.is-disliked {
  color: var(--dislike);
}

.comment-replies {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 4px;
  border-left: 2px solid var(--border);
}

.reply-box {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.reply-box .input {
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-pill);
}

.comment-form {
  display: flex;
  gap: 9px;
  align-items: center;
}

.comment-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px 4px 3px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.comment-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.comment-input-wrap input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 13px;
  min-width: 0;
  padding: 6px 0;
}

.comment-send {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary);
}

.comment-send:hover {
  background: var(--primary-soft);
}

.comment-send .icon {
  width: 17px;
  height: 17px;
}

.show-more-comments {
  align-self: flex-start;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
}

.show-more-comments:hover {
  color: var(--primary);
}

/* Post menu dropdown */
.menu {
  position: fixed;
  z-index: 80;
  min-width: 208px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: menu-in 140ms ease;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.menu button,
.menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.menu button:hover,
.menu a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.menu button.danger {
  color: var(--danger);
}

.menu .icon {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.menu button.danger .icon {
  color: var(--danger);
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 5px 4px;
}

/* --------------------------------------------------------------------------
   Right rail widgets
   -------------------------------------------------------------------------- */
.rail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
}

.rail-card h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 12px;
}

.rail-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.rail-user .meta {
  flex: 1;
  min-width: 0;
}

.rail-user .name {
  font-size: 13px;
  font-weight: 700;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-user .handle {
  font-size: 11px;
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-user .btn {
  padding: 6px 11px;
  font-size: 11.5px;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition);
}

.rail-link:hover {
  background: var(--surface-hover);
}

.rail-link .icon {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.trend-tag {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px;
  border-radius: 10px;
  transition: background var(--transition);
}

.trend-tag:hover {
  background: var(--surface-hover);
}

.trend-tag strong {
  font-size: 13px;
}

.trend-tag span {
  font-size: 11px;
  color: var(--muted);
}

.rail-footer {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.7;
}

/* --------------------------------------------------------------------------
   Reels
   -------------------------------------------------------------------------- */
.reels-page {
  position: relative;
  height: calc(100dvh - var(--topbar-h) - 48px);
  min-height: 480px;
  max-height: 900px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #05060b;
  border: 1px solid var(--border);
}

.reels-feed {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior-y: contain;
}

.reels-feed::-webkit-scrollbar {
  display: none;
}

.reel {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05060b;
}

.reel video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #05060b;
}

.reel-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(.8);
}

.reel-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px 20px 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, .8) 0%, rgba(0, 0, 0, .25) 34%, transparent 62%);
  pointer-events: none;
  color: #fff;
}

.reel-overlay > * {
  pointer-events: auto;
}

.reel-info {
  max-width: calc(100% - 78px);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.reel-author {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
}

.reel-author .avatar {
  border: 1.5px solid rgba(255, 255, 255, .8);
}

.reel-author .follow-btn {
  margin-left: 4px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .12);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  backdrop-filter: blur(4px);
}

.reel-author .follow-btn.is-following {
  background: rgba(255, 255, 255, .9);
  color: #111;
}

.reel-caption {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, .94);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

.reel-audio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .8);
  overflow: hidden;
  white-space: nowrap;
}

.reel-actions {
  position: absolute;
  right: 12px;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.reel-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

.reel-action .icon-wrap {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(20, 20, 28, .42);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(8px);
  transition: background var(--transition), transform var(--transition);
}

.reel-action:hover .icon-wrap {
  background: rgba(255, 255, 255, .2);
  transform: scale(1.06);
}

.reel-action.is-liked {
  color: var(--like);
}

.reel-action.is-liked .icon-wrap {
  color: #fff;
  background: var(--like);
  border-color: transparent;
}

.reel-action.is-disliked {
  color: var(--dislike);
}

.reel-action.is-disliked .icon-wrap {
  background: var(--dislike);
  color: #fff;
  border-color: transparent;
}

.reel-action .icon {
  width: 21px;
  height: 21px;
}

.reel-like-icon {
  transition: transform 180ms ease;
}

.reel-action.is-liked .reel-like-icon {
  transform: scale(1.12);
}

.reel-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  color: #fff;
  z-index: 2;
}

.reel-top .title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.reel-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .18);
  z-index: 3;
}

.reel-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
}

.reel-play-toggle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition);
  pointer-events: none;
  z-index: 2;
}

.reel.is-paused .reel-play-toggle {
  opacity: 1;
}

.reel-play-toggle .icon {
  width: 28px;
  height: 28px;
}

.reel-hint {
  position: absolute;
  right: 18px;
  top: 60px;
  font-size: 11px;
  color: rgba(255, 255, 255, .65);
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 2;
}

.reel-upload-zone {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone .icon {
  width: 30px;
  height: 30px;
  color: var(--primary);
}

.drop-zone strong {
  color: var(--text);
  font-size: 14px;
}

.reel-comments-sheet {
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   Friends
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--radius-pill);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab .badge-count {
  height: 17px;
  min-width: 17px;
  font-size: 10px;
}

.friends-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search-inline {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.search-inline .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 17px;
  height: 17px;
}

.search-inline .input {
  padding-left: 38px;
  border-radius: var(--radius-pill);
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition), transform var(--transition);
}

.user-card:hover {
  border-color: var(--border-strong);
}

.user-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-card .name {
  font-weight: 700;
  font-size: 13.5px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card .handle {
  font-size: 11.5px;
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card .actions {
  display: flex;
  gap: 6px;
}

.user-card .actions .btn {
  flex: 1;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.user-row:hover {
  background: var(--surface-2);
}

.user-row .meta {
  flex: 1;
  min-width: 0;
}

.user-row .meta strong {
  display: block;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row .meta span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row .row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.suggest-card {
  background: linear-gradient(160deg, var(--primary-soft), transparent 70%), var(--surface);
}

/* --------------------------------------------------------------------------
   Messenger
   -------------------------------------------------------------------------- */
.messenger-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-h) - 110px);
  min-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.conv-pane {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-2);
}

.conv-head {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.conv-head .row-between h2 {
  font-size: 17px;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
}

.conv-item:hover {
  background: var(--surface-hover);
}

.conv-item.active {
  background: var(--primary-soft);
}

.conv-item .meta {
  flex: 1;
  min-width: 0;
}

.conv-item .name {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item .preview {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.conv-item .aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.conv-item .time {
  font-size: 10px;
  color: var(--muted-2);
}

.unread-pill {
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  min-height: 62px;
  background: var(--surface);
}

.chat-header .meta {
  flex: 1;
  min-width: 0;
}

.chat-header .name {
  font-size: 14.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header .sub {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header .sub.is-online {
  color: var(--success);
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chat-actions .icon-btn {
  width: 36px;
  height: 36px;
}

.chat-actions .icon-btn .icon {
  width: 19px;
  height: 19px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background:
    radial-gradient(600px 320px at 100% 0%, var(--primary-soft), transparent 70%),
    var(--surface);
}

.message-day {
  align-self: center;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 99px;
  margin: 10px 0 6px;
}

.message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 82%;
  margin-top: 3px;
  position: relative;
}

.message.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.other {
  align-self: flex-start;
}

.message.show-author {
  margin-top: 12px;
}

.message-avatar {
  width: 28px;
  flex-shrink: 0;
}

.message-avatar .avatar {
  width: 28px !important;
  height: 28px !important;
}

.message-content {
  min-width: 0;
}

.message-author {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 3px 6px;
}

.bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-soft);
  overflow-wrap: anywhere;
  width: fit-content;
  max-width: 100%;
}

.message.other .bubble {
  border-bottom-left-radius: 5px;
}

.message.mine .bubble {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
  border-bottom-right-radius: 5px;
  margin-left: auto;
}

.bubble .message-text {
  white-space: pre-wrap;
}

.bubble .mention {
  color: inherit;
  text-decoration: underline;
}

.bubble img,
.bubble video {
  display: block;
  border-radius: 10px;
  max-width: 100%;
  max-height: 300px;
  margin-bottom: 6px;
  background: #000;
}

.bubble .message-media-only {
  margin: -5px -9px;
}

.bubble .message-media-only img,
.bubble .message-media-only video {
  margin: 0;
  border-radius: 14px;
  max-height: 320px;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  color: var(--muted-2);
  padding: 2px 6px 0;
  flex-wrap: wrap;
}

.message.mine .message-meta {
  justify-content: flex-end;
}

.message-meta .read {
  color: var(--primary);
  font-weight: 700;
}

.message-meta .edited {
  font-style: italic;
}

.message-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
  margin-bottom: 4px;
}

.message:hover .message-tools,
.message:focus-within .message-tools {
  opacity: 1;
}

.message-tools button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.message-tools button:hover {
  color: var(--text);
  background: var(--surface-3);
}

.message-tools .icon {
  width: 12px;
  height: 12px;
}

.message-quote {
  border-left: 2.5px solid var(--primary);
  background: rgba(127, 127, 160, .1);
  border-radius: 8px;
  padding: 5px 8px;
  margin-bottom: 5px;
  font-size: 11.5px;
  line-height: 1.4;
  opacity: .9;
}

.message-quote strong {
  display: block;
  font-size: 10.5px;
  margin-bottom: 1px;
}

.message.mine .message-quote {
  border-left-color: rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

.message-reactions {
  display: flex;
  gap: 3px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}

.reaction-chip:hover {
  border-color: var(--border-strong);
}

.reaction-chip.mine {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.emoji-pop {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 20;
  display: flex;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px;
  box-shadow: var(--shadow-md);
}

.message.mine .emoji-pop {
  left: auto;
  right: 0;
}

.emoji-pop button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
}

.emoji-pop button:hover {
  background: var(--surface-2);
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 18px 8px;
  font-size: 11px;
  color: var(--muted);
  min-height: 26px;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.chat-composer {
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
  background: var(--surface);
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-left: 3px solid var(--primary);
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 11.5px;
}

.reply-preview .grow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attach-preview {
  position: relative;
  display: inline-block;
  margin-bottom: 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.composer-attach-preview img,
.composer-attach-preview video {
  display: block;
  max-height: 130px;
  max-width: 220px;
}

.composer-attach-preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  display: grid;
  place-items: center;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.composer-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 18px;
  padding: 10px 14px;
  max-height: 120px;
  font-size: 13.5px;
  line-height: 1.45;
  min-height: 42px;
  outline: none;
}

.composer-row textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-gradient);
  color: #fff;
  flex-shrink: 0;
  transition: transform var(--transition), filter var(--transition);
}

.send-btn:hover {
  filter: brightness(1.08);
  transform: scale(1.04);
}

.send-btn:disabled {
  opacity: .5;
  transform: none;
}

.send-btn .icon {
  width: 18px;
  height: 18px;
}

.attach-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}

.attach-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.attach-btn input {
  display: none;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  padding: 30px;
  text-align: center;
  background: var(--surface);
}

.chat-empty .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 22px;
}

.messenger-mobile-back {
  display: none;
}

.group-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* --------------------------------------------------------------------------
   Modals, sheets, menus
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 180ms ease;
  overflow-y: auto;
}

.modal-overlay.visible {
  opacity: 1;
}

.modal-card {
  width: min(540px, 100%);
  max-height: calc(100dvh - 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(.98);
  transition: transform 180ms ease;
  overflow: hidden;
  margin: auto;
}

.modal-overlay.visible .modal-card {
  transform: none;
}

.modal-wide {
  width: min(780px, 100%);
}

.modal-sm {
  width: min(420px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 17px;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.confirm-message {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.confirm-message strong {
  color: var(--text);
}

/* Search palette */
.search-overlay .modal-card {
  width: min(620px, 100%);
  align-self: flex-start;
  margin-top: 8vh;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-field input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 16px;
  padding: 4px 0;
}

.search-results {
  max-height: 52vh;
  overflow-y: auto;
  padding: 8px;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  width: 100%;
  text-align: left;
  transition: background var(--transition);
}

.search-result:hover,
.search-result.active {
  background: var(--surface-hover);
}

.search-result .meta {
  flex: 1;
  min-width: 0;
}

.search-result .name {
  font-weight: 700;
  font-size: 13.5px;
  display: block;
}

.search-result .handle {
  font-size: 11.5px;
  color: var(--muted);
}

.search-hint {
  padding: 26px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.search-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
  color: var(--muted-2);
  padding: 12px 12px 6px;
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transform: translateY(14px);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  max-width: 100%;
}

.toast.visible {
  opacity: 1;
  transform: none;
}

.toast-success .icon { color: var(--success); }
.toast-error .icon { color: var(--danger); }
.toast-info .icon { color: var(--primary); }

.toast .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Notifications
   -------------------------------------------------------------------------- */
.notif-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 90;
  opacity: 0;
  transition: opacity 180ms ease;
}

.notif-backdrop.visible {
  opacity: 1;
}

.notif-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 100vw);
  z-index: 95;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(.2, .8, .2, 1);
  display: flex;
  flex-direction: column;
}

.notif-panel.visible {
  transform: none;
}

.notif-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.notif-header h2 {
  font-size: 17px;
  flex: 1;
}

.notif-tools {
  display: flex;
  gap: 2px;
}

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.notification {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  text-align: left;
  width: 100%;
}

.notification:hover {
  background: var(--surface-2);
}

.notification.unread {
  background: var(--primary-soft);
}

.notif-visual {
  position: relative;
  flex-shrink: 0;
}

.notif-bubble {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.notif-bubble .icon {
  width: 11px;
  height: 11px;
}

.notif-bubble.like { color: var(--like); }
.notif-bubble.comment { color: #22c55e; }
.notif-bubble.friend { color: var(--primary); }
.notif-bubble.message { color: #0ea5e9; }
.notif-bubble.call { color: var(--success); }
.notif-bubble.account { color: var(--warning); }

.notification .notif-main {
  flex: 1;
  min-width: 0;
}

.notification .notif-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-soft);
  padding-right: 18px;
}

.notification .notif-text strong {
  color: var(--text);
}

.notification .notif-time {
  font-size: 10.5px;
  color: var(--muted-2);
  margin-top: 2px;
}

.notification .notif-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 10px;
}

.notif-delete {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.notification:hover .notif-delete {
  display: grid;
}

.notif-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.notif-empty {
  padding: 60px 24px;
}

/* Full notifications page */
.notif-page-card {
  padding: 6px;
}

/* --------------------------------------------------------------------------
   Profile
   -------------------------------------------------------------------------- */
.profile-shell {
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.profile-cover {
  height: 210px;
  background:
    radial-gradient(500px 200px at 15% 10%, rgba(255, 255, 255, .2), transparent 70%),
    var(--brand-gradient);
  position: relative;
  overflow: hidden;
}

.profile-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-cover .cover-edit {
  position: absolute;
  right: 14px;
  bottom: 14px;
  background: rgba(12, 12, 20, .6);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .25);
  backdrop-filter: blur(8px);
}

.profile-content {
  padding: 0 22px 20px;
}

.profile-identity {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-top: -46px;
  position: relative;
  flex-wrap: wrap;
}

.profile-avatar-lg {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 4px solid var(--surface);
  overflow: hidden;
  background: var(--surface-3);
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.profile-avatar-lg .avatar {
  width: 104px !important;
  height: 104px !important;
}

.profile-identity-main {
  flex: 1;
  min-width: 200px;
  padding-top: 52px;
}

.profile-identity h1 {
  font-size: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-handle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.profile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 52px;
}

.profile-bio {
  margin-top: 14px;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.6;
  max-width: 620px;
  white-space: pre-wrap;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.profile-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.profile-meta .icon {
  width: 14px;
  height: 14px;
}

.profile-stats {
  display: flex;
  gap: 22px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: none;
  border: 0;
  padding: 0;
}

.profile-stat strong {
  font-size: 17px;
  font-weight: 800;
}

.profile-stat span {
  font-size: 11.5px;
  color: var(--muted);
}

.profile-stat:hover strong {
  color: var(--primary);
}

.profile-tabs {
  display: flex;
  gap: 2px;
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 8px;
}

.profile-tab {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.profile-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.profile-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.profile-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-3);
  cursor: pointer;
}

.profile-tile img,
.profile-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 300ms ease;
}

.profile-tile:hover img {
  transform: scale(1.04);
}

.profile-tile .tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent 55%);
  display: flex;
  align-items: flex-end;
  padding: 8px;
  gap: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transition: opacity var(--transition);
}

.profile-tile:hover .tile-overlay {
  opacity: 1;
}

.profile-tile .tile-overlay span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.profile-tile.text-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: center;
  overflow: hidden;
}

.profile-tile .video-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  border-radius: 6px;
  padding: 2px 5px;
  display: inline-flex;
  gap: 3px;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
}

.profile-tile .video-badge .icon {
  width: 11px;
  height: 11px;
}

.photo-viewer img,
.photo-viewer video {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: #000;
}

.photo-viewer .caption {
  margin-top: 12px;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.6;
}

/* Settings */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row .meta {
  flex: 1;
  min-width: 0;
}

.settings-row .meta strong {
  display: block;
  font-size: 13.5px;
}

.settings-row .meta span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.5;
}

.settings-section h2 {
  font-size: 15px;
  margin-bottom: 4px;
}

.settings-section > p {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.theme-choices {
  display: flex;
  gap: 8px;
}

.theme-choice {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  font-weight: 700;
  transition: border-color var(--transition), background var(--transition);
}

.theme-choice:hover {
  border-color: var(--border-strong);
}

.theme-choice.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.theme-swatch {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.theme-swatch.dark {
  background: linear-gradient(135deg, #0b0c13, #242537);
}

.theme-swatch.light {
  background: linear-gradient(135deg, #fff, #eef0f8);
}

.theme-swatch.system {
  background: linear-gradient(135deg, #0b0c13 0 50%, #fff 50% 100%);
}

/* Group info member rows */
.member-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}

.member-row:hover {
  background: var(--surface-2);
}

.member-row .meta {
  flex: 1;
  min-width: 0;
}

.member-row .meta strong {
  font-size: 13px;
  display: block;
}

.member-row .meta span {
  font-size: 11px;
  color: var(--muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}

.check-row:hover {
  background: var(--surface-2);
}

.check-row input {
  accent-color: var(--primary);
  width: 17px;
  height: 17px;
}

.check-row .meta {
  flex: 1;
  min-width: 0;
}

.check-row .meta strong {
  display: block;
  font-size: 13px;
}

.check-row .meta span {
  font-size: 11px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Video calls
   -------------------------------------------------------------------------- */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #07070d;
  color: #fff;
  display: flex;
  flex-direction: column;
  animation: call-in 240ms ease;
}

@keyframes call-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.call-stage {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 18px;
}

.call-video-grid {
  display: grid;
  gap: 10px;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  grid-auto-rows: 1fr;
  max-width: 1400px;
  margin: 0 auto;
}

.call-tile {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #12131d;
  border: 1px solid rgba(255, 255, 255, .07);
  min-height: 130px;
  display: grid;
  place-items: center;
}

.call-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #12131d;
}

.call-tile.local video {
  transform: scaleX(-1);
}

.call-tile.audio-only video {
  opacity: 0;
}

.call-tile-name {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  max-width: calc(100% - 20px);
}

.call-tile-name .icon {
  width: 12px;
  height: 12px;
}

.call-tile-avatar {
  display: grid;
  place-items: center;
}

.call-tile-avatar .avatar {
  width: 84px !important;
  height: 84px !important;
  font-size: 28px !important;
}

.call-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  color: rgba(255, 255, 255, .85);
  font-size: 12.5px;
  min-height: 56px;
}

.call-top .title {
  font-weight: 700;
  font-size: 14px;
}

.call-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .6);
  margin-left: auto;
  background: rgba(255, 255, 255, .06);
  padding: 4px 10px;
  border-radius: 99px;
}

.call-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.call-status.connected .dot {
  background: #34d399;
}

.call-status.failed .dot {
  background: #fb6b71;
}

.call-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #fff;
}

.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  flex-wrap: wrap;
}

.call-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .13);
  color: #fff;
  transition: background var(--transition), transform var(--transition);
}

.call-btn:hover {
  background: rgba(255, 255, 255, .2);
}

.call-btn:active {
  transform: scale(.94);
}

.call-btn.off {
  background: rgba(255, 255, 255, .92);
  color: #16162a;
}

.call-btn.danger {
  background: #ef4444;
  border-color: transparent;
}

.call-btn.accept {
  background: #22c55e;
  border-color: transparent;
}

.call-btn .icon {
  width: 23px;
  height: 23px;
}

.call-btn-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: rgba(255, 255, 255, .65);
  font-weight: 600;
}

.incoming-call-layer {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: grid;
  place-items: center;
  background: rgba(6, 6, 12, .82);
  backdrop-filter: blur(14px);
  padding: 20px;
}

.incoming-card {
  width: min(360px, 100%);
  background: linear-gradient(180deg, #1b1c2b, #101018);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 26px;
  padding: 30px 24px 24px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  animation: incoming 300ms ease;
}

@keyframes incoming {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.incoming-card .avatar {
  width: 84px !important;
  height: 84px !important;
  margin: 0 auto 14px;
  box-shadow: 0 0 0 6px rgba(108, 92, 231, .18);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 6px rgba(108, 92, 231, .16); }
  50% { box-shadow: 0 0 0 14px rgba(108, 92, 231, .06); }
}

.incoming-card h3 {
  font-size: 19px;
  color: #fff;
}

.incoming-card p {
  font-size: 12.5px;
  color: rgba(255, 255, 255, .6);
  margin-top: 4px;
}

.incoming-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.incoming-actions .call-btn {
  width: 58px;
  height: 58px;
}

.call-note {
  position: absolute;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .08);
  padding: 5px 12px;
  border-radius: 99px;
  white-space: nowrap;
}

.call-mini {
  position: fixed;
  right: 18px;
  bottom: 90px;
  z-index: 180;
  width: 210px;
  border-radius: 16px;
  overflow: hidden;
  background: #101018;
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: var(--shadow-lg);
}

.call-mini video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: #000;
}

.call-mini .mini-bar {
  display: flex;
  align-items: center;
  padding: 7px 9px;
  gap: 6px;
  color: #fff;
  font-size: 11px;
}

.call-mini .mini-bar .grow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-mini button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.call-mini button .icon {
  width: 13px;
  height: 13px;
}

/* Misc */
.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 700;
}

.verified-star {
  color: var(--primary);
  display: inline-flex;
}

.verified-star .icon {
  width: 14px;
  height: 14px;
}

/* Additional classes used by feature modules */
.friends-panel {
  margin-top: 16px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-empty {
  font-size: 12.5px;
  color: var(--muted);
  padding: 6px 2px 2px;
}

.comment-error {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
}

.danger-text {
  color: var(--danger) !important;
}

.edit-comment-form {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
  min-width: 200px;
}

.edit-comment-form .input {
  padding: 7px 10px;
  font-size: 12.5px;
  background: var(--surface);
}

.post-media.is-compact img,
.post-media.is-compact video {
  max-height: 280px;
}

.rail-reel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 12px;
  transition: background var(--transition);
}

.rail-reel:hover {
  background: var(--surface-hover);
}

.rail-reel img,
.rail-reel-fallback {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--brand-gradient-soft);
  display: grid;
  place-items: center;
  color: var(--primary);
}

.rail-reel > div {
  min-width: 0;
}

.rail-reel strong {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.rail-reel span {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

.reel-reactions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.call-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

@media (hover: none) {
  .notif-delete {
    display: grid;
  }
}

.tile-tooltip {
  position: fixed;
  z-index: 150;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  max-width: 260px;
}
