/* Fijados + buscador (popover en PC, hoja inferior en móvil) */
#psOverlay { display: none; position: fixed; inset: 0; z-index: 1400; background: transparent; }
#psOverlay.open { display: block; }
#psPanel {
  position: fixed; top: 64px; right: 16px; width: 440px; max-width: calc(100vw - 16px);
  max-height: min(78vh, 640px); display: flex; flex-direction: column;
  background: var(--bg-secondary, #1d2026); color: var(--text, #dbdee1);
  border-radius: 12px; box-shadow: 0 12px 36px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.07);
  overflow: hidden; animation: ps-pop .14s ease-out; transform-origin: top right;
}
@keyframes ps-pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } to { opacity: 1; transform: none; } }
.ps-handle { display: none; }
.ps-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.ps-title { font-weight: 700; font-size: 1rem; }
.ps-x { background: none; border: 0; color: var(--text-muted, #949ba4); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 6px; }
.ps-x:hover { color: #fff; }
#psBody { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.ps-view { display: flex; flex-direction: column; min-height: 0; }
.ps-search { display: flex; align-items: center; gap: 8px; margin: 4px 14px 8px; padding: 0 12px; height: 40px; border-radius: 8px; background: rgba(255,255,255,.06); color: var(--text-muted, #949ba4); }
.ps-search[hidden], .ps-filters[hidden] { display: none; }
.ps-input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text, #f2f3f5); font: inherit; font-size: .95rem; }
.ps-clear { background: none; border: 0; color: var(--text-muted, #949ba4); font-size: 1.2rem; cursor: pointer; }
.ps-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 14px 8px; align-items: center; }
.ps-scope { margin-left: auto; display: flex; gap: 6px; }
.ps-chip { border: 0; background: rgba(255,255,255,.06); color: var(--text-muted, #b5bac1); border-radius: 999px; padding: 4px 11px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.ps-chip:hover { background: rgba(255,255,255,.1); }
.ps-chip.on { background: var(--accent, #5865f2); color: #fff; }
.ps-count { padding: 2px 16px 6px; font-size: .74rem; color: var(--text-muted, #949ba4); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.ps-count:empty { display: none; }

.ps-list { overflow-y: auto; flex: 1; min-height: 120px; padding: 0 10px 8px; scrollbar-width: thin; transition: opacity .15s; }
.ps-list.loading { opacity: .5; pointer-events: none; }
.ps-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 36px 16px; color: var(--text-muted, #8b9199); text-align: center; font-size: .92rem; }
.ps-empty p { margin: 0; }
.ps-item { padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.04); margin-bottom: 8px; cursor: pointer; }
.ps-item:hover { background: rgba(255,255,255,.07); }
.ps-item-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ps-av { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; }
.ps-av-ini { display: grid; place-items: center; font-size: .6rem; font-weight: 700; color: #fff; }
.ps-name { font-weight: 600; font-size: .88rem; color: var(--text, #f2f3f5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-where { font-size: .74rem; color: var(--text-muted, #949ba4); background: rgba(255,255,255,.07); padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.ps-time { margin-left: auto; font-size: .72rem; color: var(--text-muted, #949ba4); white-space: nowrap; }
.ps-body { margin: 6px 0 0 32px; font-size: .9rem; line-height: 1.35; overflow-wrap: anywhere; white-space: pre-wrap; }
.ps-body mark { background: rgba(250, 200, 60, .35); color: inherit; border-radius: 3px; padding: 0 1px; }
.ps-tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: rgba(88,101,242,.25); color: #c9ceff; margin-left: 4px; }
.ps-actions { display: flex; gap: 6px; margin: 8px 0 0 32px; }
.ps-act { border: 0; background: rgba(255,255,255,.07); color: var(--text, #dbdee1); border-radius: 6px; padding: 4px 10px; font-size: .76rem; font-weight: 600; cursor: pointer; }
.ps-act:hover { background: rgba(255,255,255,.13); }
.ps-act.warn:hover { background: #ed4245; color: #fff; }
.ps-act:disabled { opacity: .5; cursor: default; }

.ps-pager { display: flex; justify-content: center; align-items: center; gap: 4px; padding: 8px 10px 12px; border-top: 1px solid rgba(255,255,255,.06); }
.ps-pager:empty { display: none; }
.ps-pg { min-width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(255,255,255,.06); color: var(--text, #dbdee1); font-weight: 600; cursor: pointer; }
.ps-pg:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.ps-pg.on { background: var(--accent, #5865f2); color: #fff; }
.ps-pg:disabled { opacity: .35; cursor: default; }
.ps-dots { color: var(--text-muted, #949ba4); padding: 0 2px; }

/* marca de fijado en los mensajes */
.message-card.is-pinned::after, [data-msg-id].is-pinned.dm-msg::after {
  content: ""; position: absolute; top: 6px; right: 12px; width: 14px; height: 14px; opacity: .55; pointer-events: none;
  background: currentColor; color: #f0b232;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 3l5 5-1.4 1.4-1.1-.4-3.7 3.7.3 3.2-1.4 1.4-3.2-3.2-5.4 5.4-1.4-1.4 5.4-5.4-3.2-3.2 1.4-1.4 3.2.3 3.7-3.7-.4-1.1z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 3l5 5-1.4 1.4-1.1-.4-3.7 3.7.3 3.2-1.4 1.4-3.2-3.2-5.4 5.4-1.4-1.4 5.4-5.4-3.2-3.2 1.4-1.4 3.2.3 3.7-3.7-.4-1.1z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.message-card.is-pinned { position: relative; }
.message-card.ps-flash { animation: ps-flash 2.2s ease-out; }
@keyframes ps-flash { 0%, 35% { background: rgba(88,101,242,.28); } 100% { background: transparent; } }

/* buscador de la cabecera (PC) */
.hdr-search { position: relative; width: 190px; margin-right: 8px; }
.hdr-search input { width: 100%; height: 28px; box-sizing: border-box; border: 0; outline: 0; border-radius: 6px; background: rgba(255,255,255,.07); color: var(--text, #dbdee1); font: inherit; font-size: .82rem; padding: 0 10px; cursor: text; }
.hdr-search input:focus { background: rgba(255,255,255,.1); }
@media (max-width: 768px) { .hdr-search { display: none; } }
html.lock-mobile-layout .hdr-search { display: none; }

/* pestaña "Mensajes fijados" del panel de miembros (móvil) */
#mpPinned.ps-embedded { display: flex !important; flex-direction: column; align-items: stretch !important; justify-content: flex-start !important; gap: 0 !important; font-size: 1rem; overflow: hidden; padding-top: 6px; }
#mpPinned.ps-embedded .ps-list { max-height: none; flex: 1; }

/* móvil: hoja inferior */
@media (max-width: 768px) {
  #psOverlay.open { background: rgba(0,0,0,.5); }
  #psPanel { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0; width: 100%; max-width: 100%; max-height: 86vh; border-radius: 18px 18px 0 0; animation: ps-up .22s ease-out; transform-origin: bottom; }
  .ps-handle { display: block; width: 40px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); margin: 8px auto 0; }
  @keyframes ps-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
}
html.lock-mobile-layout #psOverlay.open { background: rgba(0,0,0,.5); }
html.lock-mobile-layout #psPanel { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0; width: 100%; max-width: 100%; max-height: 86vh; border-radius: 18px 18px 0 0; }
html.lock-mobile-layout .ps-handle { display: block; width: 40px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); margin: 8px auto 0; }
