.chat-action-layer { position: fixed; inset: 0; z-index: 1000; }
.chat-action-layer [hidden] { display: none !important; }
.chat-action-panel { position: fixed; display: grid; gap: 8px; width: min(320px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); animation: chatActionIn .14s ease-out both; transform-origin: top left; }
.chat-action-panel.expanded { width: min(340px, calc(100vw - 16px)); }
.chat-action-menu, .chat-reaction-bar { border: 1px solid var(--line); background: #15222e; box-shadow: 0 12px 36px #000a; }
.chat-action-menu { display: grid; padding: 6px; border-radius: 14px; overflow-y: auto; }
.chat-action-item { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 46px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--ink, #e8f1f5); font-size: 16px; text-align: start; cursor: pointer; }
.chat-action-item:hover, .chat-action-item:focus-visible { background: #ffffff14; outline: 0; }
.chat-action-item:disabled { opacity: .45; cursor: default; }
.chat-action-item svg { flex: 0 0 24px; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chat-action-item.danger { color: var(--danger, #ff6b7d); }
.chat-reaction-bar { border-radius: 26px; padding: 5px 8px; }
.chat-reaction-row { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.chat-reaction-btn { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 25px; line-height: 1; cursor: pointer; transition: transform .12s; }
.chat-reaction-btn:hover, .chat-reaction-btn:focus-visible { transform: scale(1.22); outline: 0; }
.chat-reaction-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--teal) 28%, transparent); }
.chat-reaction-more { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: #ffffff1f; color: var(--ink, #e8f1f5); cursor: pointer; }
.chat-reaction-more svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.chat-reaction-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.chat-reaction-grid { display: flex; flex-wrap: wrap; gap: 2px; max-height: min(260px, 45dvh); margin-top: 6px; overflow-y: auto; }
@keyframes chatActionIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-action-panel { animation: none; } }

.message-actionable { cursor: pointer; }
.message-actionable:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.message-actionable.msg-selectable { position: relative; padding-inline-start: 38px; }
.message-actionable .msg-check { position: absolute; inset-inline-start: 9px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border: 2px solid #ffffff80; border-radius: 50%; }
.message-actionable.msg-selected .msg-check { border-color: var(--teal); background: var(--teal) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4 8-9' fill='none' stroke='%23062029' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.message-actionable.msg-selected { box-shadow: 0 0 0 2px var(--teal); }
.msg-pin-mark { display: inline-block; width: 12px; height: 12px; margin-inline-end: 4px; vertical-align: -1px; opacity: .75; }
.msg-pin-mark svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.chat-select-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); }
.chat-select-bar[hidden] { display: none; }
.chat-select-bar strong { flex: 1; min-width: 0; }
.chat-select-bar button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-raised); color: var(--ink, #e8f1f5); cursor: pointer; }
.chat-select-bar button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-select-bar button.danger { color: var(--danger, #ff6b7d); }
.chat-select-bar button:disabled { opacity: .45; cursor: default; }
@media (max-width: 520px) { .chat-select-bar button span { display: none; } }

.chat-pin-bar { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--panel); color: var(--ink, #e8f1f5); text-align: start; cursor: pointer; }
.chat-pin-bar[hidden] { display: none; }
.chat-pin-bar svg { flex: 0 0 22px; width: 22px; height: 22px; fill: none; stroke: var(--teal); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-pin-copy { display: grid; flex: 1; min-width: 0; border-inline-start: 3px solid var(--teal); padding-inline-start: 10px; }
.chat-pin-copy strong { color: var(--teal); font-size: 12px; }
.chat-pin-copy span { overflow: hidden; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }

.chat-choice { width: min(340px, calc(100vw - 24px)); padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-raised); color: var(--ink, #e8f1f5); }
.chat-choice::backdrop { background: #000a; }
.chat-choice h2 { margin: 0 0 8px; font-size: 1.1rem; }
.chat-choice p { margin: 0 0 12px; color: var(--muted); }
.chat-choice-actions { display: grid; gap: 8px; }
.chat-choice-btn { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: inherit; cursor: pointer; }
.chat-choice-btn:hover, .chat-choice-btn:focus-visible { background: #ffffff14; }
.chat-choice-btn.danger { color: var(--danger, #ff6b7d); }

.chat-forward { width: min(420px, calc(100vw - 24px)); max-height: min(560px, 86dvh); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-raised); color: var(--ink, #e8f1f5); }
.chat-forward::backdrop { background: #000a; }
.chat-forward form { display: grid; grid-template-rows: auto auto minmax(0, 1fr); max-height: inherit; }
.chat-forward header { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; }
.chat-forward h2 { flex: 1; margin: 0; font-size: 1.1rem; }
.chat-forward header button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.chat-forward header svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.chat-forward input[type=search] { margin: 0 16px 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: inherit; }
.chat-forward-list { display: grid; align-content: start; gap: 2px; padding: 0 8px 12px; overflow-y: auto; }
.chat-forward-list > p { padding: 12px; color: var(--muted); }
.chat-forward-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: inherit; text-align: start; cursor: pointer; }
.chat-forward-item:hover, .chat-forward-item:focus-visible { background: #ffffff14; outline: 0; }
.chat-forward-avatar { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; overflow: hidden; border-radius: 50%; background: var(--teal); color: #062029; font-weight: 700; }
.chat-forward-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-forward-item small { display: block; color: var(--muted); }
