/* Действия с сообщением: меню ника/сообщения, кнопка ↩ и плашка ответа.
   Цвета — только переменные темы (--panel, --surface-*, --border, --text,
   --muted, --accent*): один стиль на все темы и палитры, без перекрасок под
   каждую. Подключается последним; #messages в селекторах — чтобы перебить
   старые тематические правила кнопки ↩. */

/* ---------- меню ---------- */
.ctx-menu {
  position: fixed;
  z-index: 95;
  width: min(264px, calc(100vw - 16px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.14);
  font-size: 13.5px;
  animation: ctx-in 0.12s ease-out;
}
.ctx-menu.hidden { display: none; }
@keyframes ctx-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }

.ctx-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  padding: 5px 8px 9px;
  border-bottom: 1px solid var(--border);
}
.ctx-head-icon { flex: none; width: 20px; height: 20px; border-radius: 5px; object-fit: contain; }
.ctx-head-text { display: grid; min-width: 0; line-height: 1.25; }
.ctx-head-text strong,
.ctx-head-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-head-text strong { font-size: 14px; font-weight: 700; }
.ctx-head-text small { color: var(--muted); font-size: 11.5px; }

.ctx-quote {
  display: -webkit-box;
  margin: 2px 4px 6px;
  padding: 6px 9px;
  overflow: hidden;
  border-left: 2px solid var(--accent);
  border-radius: 0 7px 7px 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.ctx-quote[hidden] { display: none; }

.ctx-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-align: left;
}
.ctx-item[hidden] { display: none; }
.ctx-item svg,
.chat-reply-compose svg,
#messages .msg-reply-btn svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}
.ctx-item svg { width: 17px; height: 17px; color: var(--muted); }
.ctx-item:hover,
.ctx-item:focus-visible { background: var(--surface-3); outline: none; }
.ctx-item:hover svg,
.ctx-item:focus-visible svg { color: var(--text); }
.ctx-primary { font-weight: 650; }
.ctx-primary svg,
.ctx-primary:hover svg { color: var(--accent); }
.ctx-danger,
.ctx-danger svg,
.ctx-danger:hover svg { color: #e5484d; }
.ctx-danger:hover,
.ctx-danger:focus-visible { background: rgba(229, 72, 77, 0.12); }
.ctx-sep { height: 1px; margin: 4px 6px; border: 0; background: var(--border); }

/* телефон: шторка снизу с затемнением */
.ctx-backdrop { position: fixed; inset: 0; z-index: 94; background: rgba(0, 0, 0, 0.42); animation: ctx-fade 0.16s ease-out; }
.ctx-backdrop.hidden { display: none; }
@keyframes ctx-fade { from { opacity: 0; } }
.ctx-menu.ctx-sheet {
  top: auto;
  right: 8px;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 8px;
  width: auto;
  max-width: 520px;
  margin-inline: auto;
  padding: 8px;
  border-radius: 18px;
  font-size: 15px;
  animation: ctx-sheet-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.ctx-menu.ctx-sheet .ctx-item { min-height: 46px; gap: 13px; padding-inline: 12px; border-radius: 11px; }
.ctx-menu.ctx-sheet .ctx-item svg { width: 19px; height: 19px; }
.ctx-menu.ctx-sheet .ctx-head { padding: 6px 10px 10px; }
@keyframes ctx-sheet-in { from { opacity: 0; transform: translateY(24px); } }

/* ---------- кнопка ↩ у сообщения (ПК, по наведению) ---------- */
#messages .msg-reply-btn {
  position: absolute;
  top: 2px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 28px;
  min-width: 0;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s;
}
#messages .msg:hover .msg-reply-btn,
#messages .msg:focus-within .msg-reply-btn { display: grid; opacity: 1; pointer-events: auto; }
#messages .msg-reply-btn:hover { border-color: var(--accent-medium); color: var(--accent); }
#messages .msg-reply-btn svg { width: 15px; height: 15px; stroke-width: 2.2; }
/* кнопка теперь висит поверх, место под неё справа больше не держим */
#messages .msg:not(.system) { padding-right: 6px; }

/* ---------- телефон: без кнопки, ответ свайпом влево или тапом ---------- */
@media (hover: none) {
  #messages .msg-reply-btn { display: none !important; }
  #messages .msg:not(.system) { min-height: 0; padding-right: 3px; touch-action: pan-y; }
}
#messages .msg { transition: transform 0.2s ease; }
#messages .msg.swiping { transition: none; }
#messages .msg::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -40px;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  border-radius: 50%;
  background: var(--surface-3) center / 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 14 4 9l5-5'/%3E%3Cpath d='M4 9h10.5a5.5 5.5 0 0 1 0 11H11'/%3E%3C/svg%3E");
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.12s, transform 0.12s, background-color 0.12s;
  pointer-events: none;
}
#messages .msg.swiping::after { opacity: 0.8; }
#messages .msg.swipe-armed::after { opacity: 1; transform: scale(1); background-color: var(--accent-medium); }

/* ---------- ответ в работе ---------- */
#messages .msg.replying {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
#messages .msg.reply-target {
  outline: none;
  background: var(--accent-medium);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* плашка «Ответ …» над полем ввода */
#chat-reply-compose {
  gap: 9px;
  margin-bottom: 4px;
  padding: 6px 6px 6px 10px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  box-shadow: inset 2px 0 0 var(--accent);
  color: var(--text);
  font-size: 12px;
}
#chat-reply-compose.hidden { display: none; }
.chat-reply-compose .reply-compose-icon { width: 16px; height: 16px; color: var(--accent); }
.chat-composer #chat-reply-compose-text { display: grid; min-width: 0; line-height: 1.3; white-space: normal; }
#chat-reply-compose-text b,
#chat-reply-compose-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chat-reply-compose-text b { color: var(--accent); font-weight: 700; }
#chat-reply-compose-text span { color: var(--muted); }
.chat-composer #chat-reply-cancel {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 7px;
  color: var(--muted);
}
.chat-composer #chat-reply-cancel:hover { background: var(--surface-3); color: var(--text); }
.chat-composer #chat-reply-cancel svg { width: 14px; height: 14px; stroke-width: 2.4; }

/* ---------- «!оценка N» засчитана (kino_vote) ---------- */
.kino-vote-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  margin-left: 6px;
  padding: 0 7px 0 6px;
  border: 1px solid var(--accent-medium);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.78em;
  line-height: 1.6;
  text-decoration: none;
  vertical-align: 1px;
  white-space: nowrap;
}
.kino-vote-chip b { color: var(--accent); font-weight: 800; }
.kino-vote-chip span { overflow: hidden; max-width: 16em; text-overflow: ellipsis; }
.kino-vote-chip:hover { border-color: var(--accent); }

/* подсказка про чат на карточке фильма на плеере */
.stream-kino-cta small { display: block; margin-top: 2px; color: rgba(255, 255, 255, 0.62); font-size: 10px; font-weight: 600; }
.stream-kino-cta code { padding: 0 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); color: #fff; font: inherit; font-weight: 750; }
