/* 23.11: закрепление сообщений. Только transform/opacity в анимациях, цели нажатия от 48 px, шрифт 16+ px в основном тексте.
   Переменные --wa-* заданы на .chat-page (тёмная и светлая темы); окна лежат в body, поэтому у них свои --pin-*. */

/* ---------- полоса над перепиской ---------- */
.pin-strip { display: flex; align-items: stretch; flex: 0 0 auto; min-height: 56px; width: 100%; box-sizing: border-box;
    background: var(--wa-bar, #202c33); color: var(--wa-text, #e9edef); border-bottom: 1px solid rgba(128, 128, 128, .22); }
.pin-strip[hidden] { display: none; }
.pin-strip button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.pin-strip-main { flex: 1 1 auto; min-width: 0; min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 12px;
    background: none; border: 0; text-align: left; cursor: pointer; }
.pin-strip-bar { flex: 0 0 3px; align-self: stretch; margin: 6px 0; border-radius: 2px; background: #00a884; }
.pin-strip-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pin-strip-label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; line-height: 1.25; color: #2bd1a8; }
.pin-strip-label svg { width: 14px; height: 14px; flex: 0 0 14px; }
.pin-strip-count { font-weight: 500; opacity: .9; }
.pin-strip-text { font-size: 16px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-strip-btn { flex: 0 0 48px; width: 48px; min-height: 48px; align-self: center; display: flex; align-items: center; justify-content: center;
    padding: 0; background: none; border: 0; border-radius: 12px; cursor: pointer; opacity: .85; }
.pin-strip-btn[hidden] { display: none; }
.pin-strip-main:active, .pin-strip-btn:active { background: rgba(128, 128, 128, .16); }
.pin-strip button:focus-visible, .pin-float:focus-visible, .pin-ov button:focus-visible { outline: 2px solid #53bdeb; outline-offset: -2px; }
html:not(.dark-theme) .pin-strip-label { color: #00695a; }
@media (max-width: 340px) { .pin-strip-main { gap: 8px; padding-left: 8px; } .pin-strip-btn.pin-prev { display: none; } }

/* отметка в самой ленте: булавка рядом со временем */
.chat-messages.pins-on .message.pin-on .msg-time::before { content: ''; display: inline-block; width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px;
    background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z'/%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 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z'/%3E%3C/svg%3E") center / contain no-repeat; }
.chat-messages.pins-on .message.pin-on .msg-time { color: #2bd1a8; opacity: 1; }
html:not(.dark-theme) .chat-messages.pins-on .message.pin-on .msg-time { color: #00695a; }
/* телефон: долгое нажатие вместо выделения текста */
@media (hover: none) { .chat-messages.pins-on .message { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } }

/* мягкая подсветка найденного сообщения (только opacity) */
.pin-flash-layer { position: absolute; inset: 0; border-radius: inherit; background: rgba(0, 168, 132, .38); pointer-events: none; opacity: 0; animation: pinFlash 1.7s ease-out both; }
@keyframes pinFlash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pin-flash-layer { animation: pinFlashRm 1.7s linear both; } @keyframes pinFlashRm { 0%, 70% { opacity: .8; } 100% { opacity: 0; } } }

/* ---------- булавка рядом с сообщением (ПК) ---------- */
.pin-float { position: absolute; z-index: 6; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; background: none;
    color: var(--wa-text, #e9edef); cursor: pointer; opacity: 0; visibility: hidden; transition: opacity .15s ease; -webkit-tap-highlight-color: transparent; }
.pin-float.show { opacity: 1; visibility: visible; }
.pin-float::before { content: ''; position: absolute; width: 34px; height: 34px; border-radius: 50%; background: var(--wa-bar, #202c33); box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.pin-float svg { position: relative; width: 18px; height: 18px; }
.pin-float:hover::before { background: rgba(0, 168, 132, .3); }
.pin-float[aria-pressed="true"] { color: #2bd1a8; }
html:not(.dark-theme) .pin-float[aria-pressed="true"] { color: #00695a; }

/* ---------- окна ---------- */
.pin-ov { --pin-bg: #1f2c34; --pin-text: #e9edef; --pin-sub: rgba(233, 237, 239, .72); --pin-line: rgba(255, 255, 255, .12); --pin-btn: rgba(255, 255, 255, .1); --pin-card: rgba(255, 255, 255, .06);
    position: fixed; inset: 0; z-index: 10055; background: rgba(0, 0, 0, .55); opacity: 0; visibility: hidden; transition: opacity .18s ease, visibility 0s linear .18s; color: var(--pin-text); font-family: inherit; }
html:not(.dark-theme) .pin-ov { --pin-bg: #ffffff; --pin-text: #111b21; --pin-sub: #54656f; --pin-line: rgba(0, 0, 0, .12); --pin-btn: rgba(0, 0, 0, .06); --pin-card: #f3f4f6; }
.pin-ov.open { opacity: 1; visibility: visible; transition: opacity .18s ease; }
.pin-ov button { font: inherit; -webkit-tap-highlight-color: transparent; }

/* нижний лист при долгом нажатии */
.pin-sheet { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; width: 100%; max-width: 520px; box-sizing: border-box; background: var(--pin-bg);
    border-radius: 20px 20px 0 0; padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateY(100%); transition: transform .22s ease; box-shadow: 0 -6px 30px rgba(0, 0, 0, .35); }
.pin-ov.open .pin-sheet { transform: translateY(0); }
.pin-sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--pin-line); margin: 2px auto 12px; }
.pin-sheet-quote { font-size: 16px; line-height: 1.4; color: var(--pin-sub); margin: 0 4px 12px; max-height: 4.2em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; word-break: break-word; }
.pin-sheet-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; margin: 0 0 8px; padding: 0 16px; border: 0; border-radius: 14px;
    background: var(--pin-btn); color: var(--pin-text); font-size: 17px; font-weight: 600; cursor: pointer; }
.pin-sheet-btn:active { filter: brightness(.9); }
.pin-sheet-main { background: #00806a; color: #fff; }
.pin-sheet-cancel { margin-bottom: 0; background: transparent; border: 1px solid var(--pin-line); font-weight: 500; }

/* окно «Все закреплённые» */
.pin-list-ov { display: flex; align-items: flex-end; justify-content: center; }
.pin-list-card { width: 100%; max-width: 560px; max-height: min(88vh, 760px); max-height: min(88dvh, 760px); display: flex; flex-direction: column; box-sizing: border-box; background: var(--pin-bg);
    border-radius: 20px 20px 0 0; transform: translateY(100%); transition: transform .22s ease; box-shadow: 0 -6px 30px rgba(0, 0, 0, .35); padding-bottom: env(safe-area-inset-bottom, 0px); }
.pin-ov.open .pin-list-card { transform: translateY(0); }
.pin-list-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 16px; min-height: 56px; border-bottom: 1px solid var(--pin-line); }
.pin-list-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.25; color: var(--pin-text); }
.pin-list-x { flex: 0 0 48px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--pin-text); cursor: pointer; }
.pin-list-x:active { background: var(--pin-btn); }
.pin-list-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.pin-card { background: var(--pin-card); border-radius: 14px; padding: 12px; }
.pin-card-who { font-size: 14px; font-weight: 700; color: #2bd1a8; margin-bottom: 4px; }
html:not(.dark-theme) .pin-card-who { color: #00695a; }
.pin-card-text { font-size: 17px; line-height: 1.42; color: var(--pin-text); word-break: break-word; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.pin-card-note { margin-top: 8px; font-size: 14.5px; color: var(--pin-sub); }
.pin-card-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pin-btn { flex: 1 1 calc(50% - 4px); min-width: 0; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 10px; border: 0; border-radius: 12px;
    background: var(--pin-btn); color: var(--pin-text); font-size: 16px; font-weight: 600; cursor: pointer; }
.pin-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-btn:active { filter: brightness(.9); }
.pin-btn-go { flex: 1 1 100%; background: #00806a; color: #fff; }
@media (max-width: 340px) { .pin-btn svg { display: none; } }

/* ПК: окна по центру */
@media (min-width: 769px) {
    .pin-list-ov { align-items: center; }
    .pin-list-card { border-radius: 20px; transform: translateY(14px); padding-bottom: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); }
    .pin-ov.open .pin-list-card { transform: translateY(0); }
}

/* ---------- уведомление ---------- */
.pin-toast { position: fixed; left: 50%; top: 0; z-index: 10070; max-width: min(92vw, 420px); box-sizing: border-box; padding: 12px 18px; border-radius: 14px; background: #1f2c34; color: #fff;
    font-size: 16px; line-height: 1.35; text-align: center; box-shadow: 0 6px 22px rgba(0, 0, 0, .4); pointer-events: none; opacity: 0; transform: translate(-50%, -8px); transition: opacity .18s ease, transform .18s ease; }
.pin-toast.show { opacity: 1; transform: translate(-50%, 0); }
html:not(.dark-theme) .pin-toast { background: #233138; }
@media (prefers-reduced-motion: reduce) { .pin-ov, .pin-sheet, .pin-list-card, .pin-toast, .pin-float { transition: none; } }

/* кнопки листа с атрибутом hidden (сообщение без текста) */
.pin-sheet-btn[hidden] { display: none; }
.pin-sheet { max-height: 94vh; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; }

/* телефон на боку: полоса и лист компактнее, чтобы оставить место переписке */
@media (max-height: 520px) and (orientation: landscape) {
    .pin-strip { min-height: 48px; }
    .pin-strip-main { min-height: 48px; padding-top: 2px; padding-bottom: 2px; }
    .pin-strip-bar { margin: 4px 0; }
    .pin-strip-body { flex-direction: row; align-items: center; gap: 10px; }
    .pin-strip-label { flex: 0 0 auto; }
    .pin-strip-text { flex: 1 1 auto; min-width: 0; }
    .pin-sheet-quote { display: none; }
    .pin-sheet { padding-top: 6px; }
    .pin-sheet-grab { margin-bottom: 8px; }
    .pin-sheet-btn { min-height: 48px; margin-bottom: 6px; }
    .pin-list-card { max-height: 96vh; max-height: 96dvh; }
}

/* крупный системный шрифт: подпись полосы переносится целиком, а не рвётся по буквам */
.pin-strip-label { flex-wrap: wrap; row-gap: 0; }
.pin-strip-label span { white-space: nowrap; }
