/* Universal content + comments popup system */
html.ucl-open,
html.ucl-open body { overflow: hidden !important; }

/* Hide old inline feed/profile comment lists. The new universal popup owns comments. */
.comments-wrap .comments-header,
.comments-wrap .comment-list,
.comments-wrap .comment-actions,
.comments-wrap .comment-load-more-btn,
.comments-wrap .comment-form-wrap { display: none !important; }
.comments-wrap { margin-top: .65rem; }
.comments-wrap .comment-action-row { display: flex !important; justify-content: stretch; }
.comments-wrap .comment-toggle-btn { width: 100%; min-height: 40px; border-radius: 12px !important; font-weight: 800 !important; }

.ucl.hidden { display: none !important; }
.ucl { position: fixed; inset: 0; z-index: 200000; display: flex; align-items: center; justify-content: center; color: #e8eaed; }
.ucl-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); backdrop-filter: blur(10px); }
.ucl-shell { position: relative; width: min(1480px, calc(100vw - 28px)); height: min(930px, calc(100dvh - 28px)); display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(390px, .72fr); border-radius: 24px; overflow: hidden; background: #111315; box-shadow: 0 30px 90px rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.1); }
.ucl-close { position: absolute; right: 14px; top: 12px; z-index: 10; width: 42px; height: 42px; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.1); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; display:flex; align-items:center; justify-content:center; }
.ucl-close:hover { background: rgba(255,255,255,.18); }

.ucl-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: radial-gradient(circle at top left, #20242b, #050506 62%); }
.ucl-media-panel { min-width: 0; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ucl-media-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 18px; }
.ucl-media-object { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 18px; box-shadow: 0 18px 60px rgba(0,0,0,.48); }
.ucl-media-empty { width: min(520px, 80%); min-height: 260px; border: 1px dashed rgba(255,255,255,.18); border-radius: 22px; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.62); font-weight: 800; background: rgba(255,255,255,.05); }
.ucl-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; width: 46px; height: 58px; border: 0; border-radius: 16px; background: rgba(255,255,255,.12); color: #fff; font-size: 42px; line-height: 1; cursor: pointer; }
.ucl-prev { left: 14px; }
.ucl-next { right: 14px; }
.ucl-nav:hover { background: rgba(255,255,255,.22); }
.ucl-media-counter { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 7px 12px; border-radius: 999px; background: rgba(0,0,0,.42); color: #fff; font-size: 13px; font-weight: 900; }

.ucl-content-panel { border-top: 1px solid rgba(255,255,255,.1); background: rgba(9,10,12,.92); padding: 14px 18px 16px; max-height: 270px; overflow: auto; }
.ucl-author { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.ucl-author-avatar img { width: 44px; height: 44px; object-fit: cover; border-radius: 999px; border: 2px solid rgba(255,255,255,.22); }
.ucl-author-copy { min-width: 0; display: flex; flex-direction: column; }
.ucl-author-name { color: #fff; font-weight: 900; text-decoration: none; }
.ucl-author-copy span { color: rgba(255,255,255,.62); font-size: 13px; }
.ucl-open-link { margin-left: auto; color: #fff; background: rgba(24,119,242,.9); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 900; font-size: 12px; }
.ucl-content h1 { margin: 0 0 8px; font-size: clamp(18px, 2vw, 26px); color: #fff; }
.ucl-body-text { color: rgba(255,255,255,.88); line-height: 1.55; font-size: 14px; }
.ucl-shared-card { margin-top: 12px; display: grid; grid-template-columns: 72px minmax(0,1fr); gap: 12px; padding: 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 16px; background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.ucl-shared-card img { width: 72px; height: 72px; object-fit: cover; border-radius: 14px; }
.ucl-shared-card p { margin: 4px 0 0; color: rgba(255,255,255,.68); max-height: 42px; overflow: hidden; }
.ucl-shared-icon { width: 72px; height: 72px; border-radius: 14px; display:flex; align-items:center; justify-content:center; background: rgba(255,255,255,.1); font-size:28px; }

.ucl-side { min-height: 0; min-width: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto auto; background: #f0f2f5; color: #111827; border-left: 1px solid rgba(255,255,255,.1); }
.ucl-side-head { padding: 16px 18px 10px; display: flex; align-items: center; justify-content: space-between; }
.ucl-side-head h2 { margin: 0; font-size: 21px; font-weight: 950; }
.ucl-side-head p { margin: 2px 0 0; color: #667085; font-size: 13px; font-weight: 700; }
.ucl-target-react { padding: 0 18px 12px; border-bottom: 1px solid rgba(15,23,42,.08); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ucl-reaction-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.ucl-reaction-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 999px; background: #fff; border: 1px solid rgba(15,23,42,.08); font-size: 12px; font-weight: 900; box-shadow: 0 4px 12px rgba(15,23,42,.05); }
.ucl-reaction-empty { color: #667085; font-size: 12px; font-weight: 800; }

.ucl-thread { min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 14px 18px 16px; overscroll-behavior: contain; }
.ucl-comment { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 9px; margin: 0 0 10px; padding-left: calc(var(--ucl-depth, 0) * 16px); }
.ucl-comment.depth-0 { padding-left: 0; }
.ucl-comment-avatar img { width: 36px; height: 36px; border-radius: 999px; object-fit: cover; border: 1px solid rgba(15,23,42,.1); background: #fff; }
.ucl-comment-main { min-width: 0; }
.ucl-comment-bubble { display: inline-block; max-width: 100%; background: #fff; color: #111827; border-radius: 18px; padding: 9px 11px; box-shadow: 0 5px 16px rgba(15,23,42,.06); border: 1px solid rgba(15,23,42,.06); }
.ucl-comment-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.ucl-comment-head a { color: #111827; font-weight: 950; text-decoration: none; font-size: 13px; }
.ucl-comment-text { margin-top: 3px; line-height: 1.38; font-size: 14px; color: #111827; overflow-wrap: anywhere; }
.ucl-comment-delete { width: 22px; height: 22px; border-radius: 999px; border: 0; background: #f1f5f9; color: #334155; cursor: pointer; font-weight: 900; }
.ucl-comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 3px 0 0 8px; min-height: 28px; }
.ucl-comment-actions .ucl-reaction-summary { font-size: 12px; }
.ucl-reply-btn { border: 0; background: transparent; color: #475467; font-weight: 900; font-size: 12px; cursor: pointer; padding: 4px 2px; }
.ucl-reply-btn:hover { color: #1877f2; }
.ucl-replies { margin-top: 8px; }

.ucl-reaction-wrap { position: relative; display: inline-flex; align-items: center; }
.ucl-like-btn { border: 0; border-radius: 999px; background: #fff; color: #344054; box-shadow: 0 4px 12px rgba(15,23,42,.07); padding: 8px 12px; font-weight: 950; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.ucl-like-btn.is-active { color: #1877f2; background: #eaf3ff; }
.ucl-reaction-wrap.is-compact .ucl-like-btn { padding: 4px 6px; box-shadow: none; background: transparent; font-size: 12px; }
.ucl-reaction-wrap.is-compact .ucl-like-btn b { display: none; }
.ucl-reaction-flyout { position: absolute; left: 0; bottom: calc(100% + 8px); display: none; align-items: center; gap: 5px; padding: 7px 8px; border-radius: 999px; background: #fff; box-shadow: 0 12px 35px rgba(15,23,42,.24); border: 1px solid rgba(15,23,42,.08); z-index: 40; white-space: nowrap; }
.ucl-reaction-wrap:hover .ucl-reaction-flyout,
.ucl-reaction-wrap:focus-within .ucl-reaction-flyout { display: inline-flex; }
.ucl-reaction-flyout button { border: 0; background: transparent; font-size: 23px; line-height: 1; padding: 5px; border-radius: 999px; cursor: pointer; transition: transform .12s ease; }
.ucl-reaction-flyout button:hover { transform: translateY(-4px) scale(1.16); }

.ucl-loader { display: none; padding: 8px 18px; color: #667085; font-weight: 800; font-size: 12px; text-align: center; }
.ucl-loader.is-visible { display: block; }
.ucl-empty, .ucl-error { margin: 20px auto; padding: 15px; text-align: center; border-radius: 18px; background: #fff; color: #667085; font-weight: 850; }
.ucl-error { color: #b42318; background: #fff1f3; }
.ucl-skeleton-line, .ucl-skeleton-block { border-radius: 14px; background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.18), rgba(255,255,255,.08)); animation: uclPulse 1.2s infinite linear; }
.ucl-skeleton-line { width: 180px; height: 34px; }
.ucl-skeleton-block { width: 100%; height: 90px; }
@keyframes uclPulse { from { opacity: .55; } 50% { opacity: 1; } to { opacity: .55; } }

.ucl-composer { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 9px; align-items: end; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid rgba(15,23,42,.08); }
.ucl-composer-avatar { width: 36px; height: 36px; object-fit: cover; border-radius: 999px; border: 1px solid rgba(15,23,42,.08); }
.ucl-composer textarea, .ucl-reply-form textarea { width: 100%; resize: none; max-height: 120px; min-height: 40px; border: 1px solid rgba(15,23,42,.1); border-radius: 18px; background: #f2f4f7; color: #111827; padding: 10px 12px; outline: none; font: inherit; }
.ucl-composer textarea:focus, .ucl-reply-form textarea:focus { border-color: #1877f2; box-shadow: 0 0 0 3px rgba(24,119,242,.13); background: #fff; }
.ucl-composer button, .ucl-reply-form button[type="submit"] { border: 0; background: #1877f2; color: #fff; font-weight: 950; border-radius: 999px; padding: 10px 14px; cursor: pointer; }
.ucl-composer button:disabled, .ucl-reply-form button:disabled { opacity: .65; cursor: wait; }
.ucl-reply-form-wrap { margin: 7px 0 8px; }
.ucl-reply-form { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 7px; align-items: end; }
.ucl-reply-form button[data-ucl-cancel-reply] { border: 0; background: transparent; color: #667085; font-weight: 900; cursor: pointer; }

@media (max-width: 980px) {
  .ucl { align-items: stretch; justify-content: stretch; }
  .ucl-shell { width: 100vw; height: 100dvh; border-radius: 0; grid-template-columns: 1fr; grid-template-rows: minmax(38dvh, 44dvh) minmax(0, 1fr); }
  .ucl-main { min-height: 0; grid-template-rows: minmax(0, 1fr) auto; }
  .ucl-media-stage { padding: 10px; }
  .ucl-media-object { border-radius: 12px; }
  .ucl-content-panel { max-height: 150px; padding: 10px 12px; }
  .ucl-content h1 { font-size: 18px; }
  .ucl-body-text { font-size: 13px; max-height: 72px; overflow: auto; }
  .ucl-side { border-left: 0; min-height: 0; grid-template-rows: auto auto minmax(0,1fr) auto auto; }
  .ucl-side-head { padding: 10px 12px 8px; }
  .ucl-target-react { padding: 0 12px 8px; }
  .ucl-thread { padding: 10px 12px 12px; }
  .ucl-comment { grid-template-columns: 34px minmax(0,1fr); padding-left: calc(var(--ucl-depth, 0) * 9px); }
  .ucl-comment-avatar img { width: 32px; height: 32px; }
  .ucl-nav { width: 38px; height: 48px; font-size: 32px; }
  .ucl-close { top: 8px; right: 8px; background: rgba(0,0,0,.38); }
  .ucl-composer { grid-template-columns: 32px minmax(0, 1fr) auto; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .ucl-composer-avatar { width: 32px; height: 32px; }
  .ucl-composer button { padding: 9px 11px; }
}

/* Universal comments repair: sorting, viewport-safe reactions, composer avatar */
.ucl-sort-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  font-size: 12px;
    color: rgb(67 67 67 / 72%);
}
.ucl-sort-row button {
    border: 1px #0b0b0b;
    border-radius: 999px;
    padding: 7px 11px;
    background: rgba(255, 255, 255, .09);
    color: rgb(74 74 74 / 78%);
    cursor: pointer;
    font-weight: 800;
    border-style: dotted;
}
.ucl-sort-row button.is-active {
  background: #1877f2;
    color: #000000;

  box-shadow: 0 8px 20px rgba(24,119,242,.26);
}
.ucl-composer-avatar,
.ucl-comment-avatar img,
.ucl-author-avatar img {
  object-fit: cover;
  background: rgba(255,255,255,.12);
}
.ucl-reaction-wrap { position: relative; }
.ucl-reaction-flyout {
  max-width: calc(100vw - 16px);
  pointer-events: auto;
  z-index: 999999;
}
.ucl-reaction-wrap.is-flyout-visible .ucl-reaction-flyout {
  display: inline-flex !important;
  opacity: 1 !important;
  visibility: visible !important;
}
@media (max-width: 720px) {
  .ucl-reaction-flyout {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    transform: none !important;
    justify-content: center;
    border-radius: 999px;
  }
}

/* Color-background posts inside the universal lightbox */
.ucl-bg-post-preview {
  width: min(92%, 720px);
  min-height: min(72dvh, 720px);
  border-radius: 26px;
  display: grid;
  place-items: center;
  padding: 36px;
  text-align: center;
  color: #fff;
  font-size: clamp(24px, 4vw, 54px);
  font-weight: 1000;
  line-height: 1.12;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
  overflow: hidden;
}
.ucl-bg-post-preview > div { max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .ucl-bg-post-preview { width: 94vw; min-height: 36dvh; border-radius: 18px; padding: 24px; font-size: clamp(20px, 8vw, 42px); }
}

/* Reaction button left, reaction totals right inside universal lightbox */
.ucl-target-react {
  justify-content: flex-start;
}
.ucl-target-react > .ucl-reaction-wrap,
.ucl-comment-actions > .ucl-reaction-wrap {
  order: 1;
}
.ucl-target-react > .ucl-reaction-summary,
.ucl-comment-actions > .ucl-reaction-summary {
  order: 2;
}
.ucl-comment-actions .ucl-reaction-chip,
.ucl-target-react .ucl-reaction-chip {
  gap: 5px;
}
.ucl-comment-actions .ucl-reaction-chip span,
.ucl-target-react .ucl-reaction-chip span {
  order: 1;
}
.ucl-comment-actions .ucl-reaction-chip b,
.ucl-target-react .ucl-reaction-chip b {
  order: 2;
}


/* Universal comments extra-small mobile hardening */
@media (max-width: 560px) {
  .ucl { align-items: flex-end; }
  .ucl-shell {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 42dvh) minmax(0, 1fr);
  }
  .ucl-main {
    grid-template-rows: minmax(0,1fr) auto;
    min-height: 0;
  }
  .ucl-media-stage { padding: 10px; }
  .ucl-media-object { max-height: calc(42dvh - 24px); width: auto; }
  .ucl-nav { width: 34px; height: 44px; font-size: 28px; border-radius: 12px; }
  .ucl-prev { left: 8px; }
  .ucl-next { right: 8px; }
  .ucl-content-panel {
    max-height: 120px;
    padding: 10px 12px 12px;
  }
  .ucl-author-avatar img { width: 36px; height: 36px; }
  .ucl-open-link { padding: 7px 10px; font-size: 11px; }
  .ucl-side {
    min-height: 0;
    grid-template-rows: auto auto auto minmax(0,1fr) auto;
  }
  .ucl-side-head {
    padding: 10px 12px 6px;
  }
  .ucl-side-head h2 { font-size: 18px; }
  .ucl-side-head p { font-size: 12px; }
  .ucl-sort-row {
    padding: 8px 10px;
    gap: 6px;
    font-size: 11px;
  }
  .ucl-sort-row button {
    padding: 6px 10px;
    font-size: 12px;
  }
  .ucl-target-react {
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  .ucl-target-react .ucl-like-btn {
    padding: 7px 10px;
    font-size: 13px;
  }
  .ucl-target-react .ucl-reaction-summary {
    gap: 5px;
    min-width: 0;
  }
  .ucl-target-react .ucl-reaction-chip {
    padding: 4px 7px;
    font-size: 11px;
  }
  .ucl-thread {
    padding: 8px 10px 10px;
  }
  .ucl-comment {
    grid-template-columns: 30px minmax(0,1fr);
    gap: 8px;
    padding-left: calc(var(--ucl-depth, 0) * 7px);
    margin-bottom: 8px;
  }
  .ucl-comment-avatar img { width: 30px; height: 30px; }
  .ucl-comment-bubble {
    padding: 8px 10px;
    border-radius: 16px;
  }
  .ucl-comment-text { font-size: 13px; line-height: 1.32; }
  .ucl-comment-actions {
    gap: 6px;
    margin-left: 4px;
    min-height: 24px;
  }
  .ucl-reply-btn, .ucl-comment-actions .ucl-reaction-summary, .ucl-comment-actions .ucl-like-btn {
    font-size: 11px;
  }
  .ucl-reaction-flyout {
    left: 8px !important;
    right: 8px !important;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    padding: 6px 8px;
    gap: 2px;
  }
  .ucl-reaction-flyout button { font-size: 21px; padding: 4px; }
  .ucl-composer {
    grid-template-columns: 28px minmax(0,1fr) auto;
    gap: 7px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .ucl-composer-avatar { width: 28px; height: 28px; }
  .ucl-composer textarea {
    min-height: 36px;
    max-height: 88px;
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 16px;
  }
  .ucl-composer button {
    padding: 8px 10px;
    min-width: 64px;
    font-size: 13px;
    border-radius: 14px;
  }
}

@media (max-width: 400px) {
  .ucl-sort-row span { width: 100%; }
  .ucl-target-react .ucl-like-btn b { display: inline; }
  .ucl-target-react .ucl-reaction-summary { width: 100%; }
  .ucl-open-link { margin-left: 0; }
  .ucl-author { align-items: flex-start; flex-wrap: wrap; }
}


/* Reaction System Rebuild Phase 3: universal comment reactions on platform layer */
.ucl-target-react > .platform-reaction-root,
.ucl-comment-actions > .platform-reaction-root,
.reply-actions > .platform-reaction-root {
  order: 1;
}
.ucl-target-react > .platform-reaction-root .platform-reaction-summary,
.ucl-comment-actions > .platform-reaction-root .platform-reaction-summary,
.reply-actions > .platform-reaction-root .platform-reaction-summary {
  order: 2;
}
.ucl-target-platform-reaction {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
}
.platform-comment-reaction-bar--ucl .platform-reaction-main {
  min-height: 24px;
  padding: 4px 7px;
  box-shadow: none;
}
.platform-comment-reaction-bar--ucl .platform-reaction-main-label {
  font-size: 12px;
}
.platform-comment-reaction-bar--ucl .platform-reaction-summary {
  font-size: 11px;
}
@media (max-width: 560px) {
  .ucl-target-platform-reaction {
    width: 100%;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  .ucl-target-platform-reaction .platform-reaction-main {
    padding: 7px 10px;
  }
  .ucl-target-platform-reaction .platform-reaction-summary {
    width: 100%;
  }
}
