/* Right-click menu: the palette's surface and accent, in a small floating card. */
.ctxmenu {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2000;
  min-width: 190px;
  max-width: 320px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 5px;
  background: var(--surface2, #18181f);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 0;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.66), 0 0 22px color-mix(in srgb, var(--accent) 14%, transparent);
  outline: none;
  /* Scale only: a menu that starts from opacity 0 stays invisible in a frame captured mid-animation. */
  animation: ctxmenu-in 90ms var(--ease);
}

@keyframes ctxmenu-in { from { transform: scale(0.98); } }
.ctxmenu:focus-visible { outline: none; }

.ctxmenu-item {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: 13px var(--mono);
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.ctxmenu-item:hover:not(:disabled),
.ctxmenu-item.on:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface2));
}

.ctxmenu-item.on:not(:disabled) {
  outline: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}

.ctxmenu-item:disabled { opacity: 0.42; cursor: default; }
.ctxmenu-item.danger .ctxmenu-label { color: var(--red, #B14242); }

.ctxmenu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ctxmenu-hint {
  font: 10.5px var(--mono);
  color: var(--faint);
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  flex: none;
}

.ctxmenu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

/* The image "Open" view: the same dimmed overlay as the chat's own image viewer. */
.overlay.ctxmenu-image { display: flex; align-items: center; justify-content: center; }
.overlay.ctxmenu-image img { max-width: 90vw; max-height: 90vh; border-radius: 0; }

@media (prefers-reduced-motion: reduce) {
  .ctxmenu { animation: none; }
}
